package org.xq.softcup.mq.admin.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.xq.softcup.mq.admin.model.MqBiz;
import org.xq.softcup.mq.admin.util.JsonResult;
import org.xq.softcup.mq.admin.service.IMqBizService;

import javax.annotation.Resource;
import java.util.List;

/**
 * 业务线控制层
 * @author admin
 */
@Controller
@RequestMapping("/biz")
public class BizController {

    @Resource
    private IMqBizService mqBizService;

    @RequestMapping("")
    public String index(Model model){

        List<MqBiz> bizList = mqBizService.findAll();
        model.addAttribute("bizList", bizList);

        return "biz/biz.index";
    }

    @RequestMapping("/save")
    @ResponseBody
    public JsonResult<String> save(MqBiz mqBiz){
        return mqBizService.add(mqBiz);
    }

    @RequestMapping("/update")
    @ResponseBody
    public JsonResult<String> update(MqBiz mqBiz){
        return mqBizService.update(mqBiz);
    }


    @RequestMapping("/remove")
    @ResponseBody
    public JsonResult<String> remove(int id){
        return mqBizService.delete(id);
    }

}
